import { request } from "@/request";

export async function fetchList(data) {
  const res = await request("/admin/role/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
export async function addRole(data) {
  return request("/admin/role/add", {
    method: "post",
    data,
  });
}

export async function updateRole(data) {
  return request("/admin/role/edit", {
    method: "post",
    data,
  });
}

export function remove(data) {
  return request(`/admin/role/delete?ids=${data.ids}`, {
    method: "post",
    data,
  });
}

// 查询管理端可用的权限
export function getPermissionList() {
  return request(`/admin/role/list/sub/permission`, {
    method: "post",
    data:{}
  });
}

// 查询所有角色
export function getRoleList() {
  return request(`/admin/role/list/all`, {
    method: "post",
    data: {},
  });
}
